# -*- coding: utf-8 -*-
import urllib


def parse_url(url):
    '''
    解析url，返回协议，域名
    :param url: 
    :return: 
    '''
    protocol = ''
    host = ''
    path = ''
    if not url:
        return protocol, host, path
    protocol, html_url = urllib.splittype(url)
    host, path = urllib.splithost(html_url)
    return protocol, host, path

def clear_ascii_extend_character(unicode_string):
    '''
    在爬取类型时，返回的unicode字符串中有ascii编码额外扩展的字符，需要清除
    :param unicode_string: 
    :return: 
    '''
    if not unicode_string:
        return u''
    extend_character = u'\xa0'
    move = dict.fromkeys((ord(c) for c in extend_character))
    output = unicode_string.translate(move)
    return output



